package peace.grapher
{
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
/**
 * 
 */
public class AxisLabel extends TextField implements IAxisLabel
{
	/**
	 * точность текстовой метки, знаков после запятой
	 */
	public var precision:int;
	/**
	 * 
	 * @param value
	 * @param precision
	 * @param format
	 * 
	 */	
	public function AxisLabel (value:Number, precision:int = 1, format:TextFormat = null)
	{
		super();
		this.precision = precision;
		defaultTextFormat = format;
		
		selectable = mouseEnabled = false;
		autoSize = TextFieldAutoSize.LEFT;

		this.value = value;
		
		mouseEnabled = false;
	}
	/**
	 * 
	 * @param n
	 * 
	 */	
	public function set value(n:Number):void
	{
		if (precision == 0)
		{
			text = Math.round(n)+"";
		}
		else
		{
			text = n.toFixed(precision);
		}
	}
	/**
	 * 
	 * @return 
	 * 
	 */	
	public function get value():Number
	{
		return Number(text);
	}
	/**
	 * 
	 * @param n
	 * @return 
	 * 
	 */	
	public function clone(n:Number):IAxisLabel
	{
		return new AxisLabel(n, precision, defaultTextFormat);
	}
	
}
}